﻿using System;
using System.Collections.Generic;
using AppfabricAdministrator.Entities.Interface;

namespace AppfabricAdministrator.Commands.Cache
{
    public class NewCache : ICommand
    {
        private string commandName = "New-Cache";
        public Boolean IsModify = false;
        public string CommandName
        {
            get
            {
                return commandName;
            }
            set
            {
                commandName = value;
            }
        }

        private Dictionary<String, Object> _parameters = new Dictionary<String, Object>(){
            {"CacheName",null},
            {"Eviction",null},
            {"Expirable",null},
            {"MinSecondaries",null},
            {"NotificationsEnabled",null},
            {"ProviderSettings",null},
            {"ProviderType",null},
            {"ReadThroughEnabled",null},
            {"Secondaries",null},
            {"Force",null},
            {"TimeToLive",null},
            {"WriteBehindEnabled",null},
            {"WriteBehindInterval",null},
            {"WriteBehindRetryCount",null},
            {"WriteBehindRetryInterval",null}
        };

        public Dictionary<string, object> Parameters
        {
            get
            {
                return _parameters;
            }
            set
            {
                _parameters = value;
            }
        }

        private string _successMessage = "Created cache {0}.";
        public string SuccessMessage
        {
            get
            {
                if (IsModify)
                {
                    return String.Format("Updated configuration for cache {0}.", Parameters["CacheName"].ToString());
                }
                else
                {
                    return String.Format(_successMessage, Parameters["CacheName"].ToString());
                }
            }
        }
    }
}
